define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'account/money/index' + location.search,
                    //add_url: 'account/money/add',
                    //edit_url: 'account/money/edit',
                    //del_url: 'account/money/del',
                    multi_url: 'account/money/multi',
                    table: 'users_account_log',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        //{field: 'user_id', title: __('User_id')},
                        //{field: 'source_id', title: __('Source_id')},
                        //{field: 'coin_type', title: __('Coin_type'), searchList: {"love":__('Love'),"study":__('Study')}, formatter: Table.api.formatter.normal},
                        {field: 'users.balance', title: __('Users.balance'), operate:'BETWEEN'},
                        {field: 'type', title: __('Type'), searchList: {"1":__('Type 1'),"2":__('Type 2'),"3":__('Type 3'),"4":__('Type 4'),"5":__('Type 5'),"6":__('Type 6'),"7":__('Type 7'),"8":__('Type 8'),"9":__('Type 9'),"10":__('Type 10')}, formatter: Table.api.formatter.normal},
                        {field: 'class', title: __('Class'), searchList: {"1":__('Class 1'),"2":__('Class 2')}, formatter: Table.api.formatter.normal},
                        {field: 'money', title: __('Money'), operate:'BETWEEN'},
                        {field: 'remark', title: __('Remark')},

                        //{field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange'},
                        {field: 'before_money', title: __('Before_money'), operate:'BETWEEN'},
                        //{field: 'users.id', title: __('Users.id')},
                        //{field: 'users.pid', title: __('Users.pid')},
                        //{field: 'users.uuid', title: __('Users.uuid')},
                        //{field: 'users.wx_openid', title: __('Users.wx_openid')},
                        //{field: 'users.password', title: __('Users.password')},
                        //{field: 'users.pay_password', title: __('Users.pay_password')},
                        {field: 'users.nickname', title: __('Users.nickname')},
                        {field: 'to_user', title: __('来源用户')},
                        //{field: 'users.truename', title: __('Users.truename')},
                        {field: 'users.mobile', title: __('Users.mobile')},
                        //{field: 'users.headimg', title: __('Users.headimg')},
                        //{field: 'users.id_card', title: __('Users.id_card')},
                        //{field: 'users.status', title: __('Users.status')},
                        //{field: 'users.alipay', title: __('Users.alipay')},
                        //{field: 'users.level', title: __('Users.level')},
                        //{field: 'users.qrcode', title: __('Users.qrcode')},
                        {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange'},
                        //{field: 'users.lover', title: __('Users.lover')},
                        //{field: 'users.province', title: __('Users.province')},
                        //{field: 'users.city', title: __('Users.city')},
                        //{field: 'users.area', title: __('Users.area')},
                        //{field: 'users.createtime', title: __('Users.createtime'), operate:'RANGE', addclass:'datetimerange'},
                        //{field: 'users.updatetime', title: __('Users.updatetime'), operate:'RANGE', addclass:'datetimerange'},
                        //{field: 'users.first_log', title: __('Users.first_log')},
                        //{field: 'users.day_log', title: __('Users.day_log')},
                        //{field: 'users.sign', title: __('Users.sign')},
                        //{field: 'users.vip_expire_time', title: __('Users.vip_expire_time'), operate:'RANGE', addclass:'datetimerange'},
                        //{field: 'users.qrcode_url', title: __('Users.qrcode_url'), formatter: Table.api.formatter.url},
                        //{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});